package com.hs.telepass.utils;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import com.hs.teleform.R;
import com.hs.telepass.MainApp;
import com.hs.telepass.manager.PreferencesManager;

public class ShortSoundUtil {
    private static ShortSoundUtil shortSoundUtil;
    private  SoundPool soundPool;
    private int sacnSoundId;
    private int unlockId;

    public ShortSoundUtil(Context context){
        soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
        sacnSoundId = soundPool.load(context, R.raw.ding, 1);
        unlockId = soundPool.load(context, R.raw.unlock, 1);
    }

    public static ShortSoundUtil getInstance() {
        if (null == shortSoundUtil) {
            shortSoundUtil = new ShortSoundUtil(MainApp.getInstance());
        }
        return shortSoundUtil;
    }

    public void scanPlay() {
        if(true == PreferencesManager.getInstance().getSoundSwitch())
            soundPool.play(sacnSoundId, 1, 1, 0, 0, 1);
    }

    public void unlock(){
        if(true == PreferencesManager.getInstance().getSoundSwitch())
            soundPool.play(unlockId, 1, 1, 0, 0, 1);
    }

}
